package com.veryGood.common.result;
import com.veryGood.common.util.Constants;


/**
 * @param <T>
 * @author guziyuan
 */
public class R<T> {
    private  Integer code;
    private String message; // 提示信息
    private T data; // 返回数据
    public static R success(){return new R(Constants.ok,Constants.message_OK);}
    public static <T> R<T> success(T code){return new R(Constants.ok,Constants.message_OK,code);}
    public static R success(String mes){return new R(Constants.ok,mes);}
    public static <T> R<T> success(String mes,T data){return new R(Constants.ok,mes,data);}

    public static R error(){return new R(Constants.error,Constants.message_ERROR);}
    public static <T> R<T> error(T code){return new R(Constants.error,Constants.message_ERROR,code);}
    public static R error(String mes){return new R(Constants.error,mes);}
    public static <T> R<T> error(String mes,T data){return new R(Constants.error,mes,data);}

    public R() {}
    public R(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public R(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }
}
